//
//  MacroDefinition.h
//  iOS开发常用的宏定义
//

#ifndef MacroDefinition_h
#define MacroDefinition_h

#ifdef __OBJC__

/** --------------日志Log-------------- */
//DEBUG  模式下打印日志,当前行
#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...)
#endif /* DEBUG */

/** --------------常用颜色宏-------------- */
#define kCOLOR_BLACK     [UIColor blackColor]
#define kCOLOR_BLUE      [UIColor blueColor]
#define kCOLOR_BROWN     [UIColor brownColor]
#define kCOLOR_CLEAR     [UIColor clearColor]
#define kCOLOR_DARKGRAY  [UIColor darkGrayColor]
#define kCOLOR_DARKTEXT  [UIColor darkTextColor]
#define kCOLOR_WHITE     [UIColor whiteColor]
#define kCOLOR_YELLOW    [UIColor yellowColor]
#define kCOLOR_RED       [UIColor redColor]
#define kCOLOR_ORANGE    [UIColor orangeColor]
#define kCOLOR_PURPLE    [UIColor purpleColor]
#define kCOLOR_LIGHTTEXT [UIColor lightTextColor]
#define kCOLOR_LIGHTGRAY [UIColor lightGrayColor]
#define kCOLOR_GREEN     [UIColor greenColor]
#define kCOLOR_GRAY      [UIColor grayColor]
#define kCOLOR_MAGENTA   [UIColor magentaColor]

#define kCOLOR_RGB(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define kCOLOR_RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

/** --------------字体-------------- */
#define kFONT(msize)        [UIFont systemFontOfSize:msize]
#define kBOLD_FONT(msize)   [UIFont boldSystemFontOfSize:msize]

/** --------------获取设备大小-------------- */
#define kSCREEN_WIDTH  ([UIScreen mainScreen].bounds.size.width)
#define kSCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

/** --------------获取View的frame相关值-------------- */
#define kVIEW_WIDTH(mview)   CGRectGetWidth(mview.frame)
#define kVIEW_HEIGHT(mview)  CGRectGetHeight(mview.frame)
#define kVIEW_MIN_X(mview)   CGRectGetMinX(mview.frame)
#define kVIEW_MIN_Y(mview)   CGRectGetMinY(mview.frame)
#define kVIEW_MAX_X(mview)   CGRectGetMaxX(mview.frame)
#define kVIEW_MAX_Y(mview)   CGRectGetMaxY(mview.frame)
#define kVIEW_MID_X(mview)   CGRectGetMidX(mview.frame)
#define kVIEW_MID_Y(mview)   CGRectGetMidY(mview.frame)

/** --------------中英状态下键盘的高度-------------- */
#define kKEYBOARD_HEIGHT_EN   (216.f)
#define kKEYBOARD_HEIGHT_CHN  (252.f)

/** --------------图片-------------- */
/*
 kBUNDLE_IMAGE(bundlePathName)的用法
 0、只能读取以.png为后缀的图片，png不能为大写。
 1、假设MyImage.bundle文件中有一张face.png图片，即路径为MyImage.bundle/face.png。
 2、UIImage *img = kBUNDLE_IMAGE(@"MyImage.bundle/face");
 */
#define kIMAGE_PATH(imgPath) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imgPath ofType:@"png"]]
/*用法类似上面的kBUNDLE_IMAGE，增加一个type参数（大小写敏感），可以读取指定类型的图片*/
#define kIMAGE_PATH_TYPE(imgPath, type) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imgPath ofType:type]]
/*只建议使用这方法来加载Assets.xcassets文件夹的小图片*/
#define kIMAGE_NAMED(imgName) [UIImage imageNamed:imgName]

/** --------------检查系统版本-------------- */
#define kSYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define kSYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define kSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define kSYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define kSYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

/** --------------常用路径-------------- */
#define kPATH_HOME        NSHomeDirectory()
#define kPATH_TEMP        NSTemporaryDirectory()
#define kPATH_DOCUMENT    [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]


#endif /* __OBJC__ */

#endif /* MacroDefinition_h */
